package com.tomowork.ExceotionResolver;

import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class ShiroException implements HandlerExceptionResolver {

    @Override
    public ModelAndView resolveException(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) {
        ModelAndView modelAndView =null ;
        if(e instanceof org.apache.shiro.session.ExpiredSessionException){
            modelAndView= new ModelAndView("login") ;
        }else{
            modelAndView= new ModelAndView("/errorsPage/unauthorizedUrl") ;
        }
        return modelAndView ;
    }
}
